import React, { useState } from 'react';
import { Button, Tooltip } from 'antd';
import './UtilsCard.css';
import { SettingCursorPath } from './SettingCursorPath';
import { DisableAutoUpdate } from './DisableAutoUpdate';
import { ResetMachineIdModal } from './ResetMachineId';
import { PostAvailableAccountModal } from './PostAvailableAccount';

interface UtilsCardProps {
    onSuccess: () => void;
}

export const UtilsCard: React.FC<UtilsCardProps> = ({ onSuccess }) => {
    const [isSettingModalOpen, setIsSettingModalOpen] = useState(false);
    const [isDisableUpdateModalOpen, setIsDisableUpdateModalOpen] = useState(false);
    const [isResetModalOpen, setIsResetModalOpen] = useState(false);
    const [isPostAccountModalOpen, setIsPostAccountModalOpen] = useState(false);

    return (
        <>
            <div className="utils-card">
                <Tooltip title="设置 Cursor 应用路径">
                    <Button type="text" onClick={() => setIsSettingModalOpen(true)}>设置Cursor路径</Button>
                </Tooltip>
                <Tooltip title="此操作不可逆，请谨慎使用">
                    <Button type="text" onClick={() => setIsDisableUpdateModalOpen(true)}>禁用自动更新</Button>
                </Tooltip>
                <Tooltip title="重置应用的机器码，高风险操作">
                    <Button type="text" onClick={() => setIsResetModalOpen(true)}>重置机器码</Button>
                </Tooltip>
                <Tooltip title="从服务器获取一个可用的 Pro 账号并自动替换">
                    <Button type="text" onClick={() => setIsPostAccountModalOpen(true)}>获取可用账号</Button>
                </Tooltip>
            </div>
            <SettingCursorPath 
                open={isSettingModalOpen}
                onClose={() => setIsSettingModalOpen(false)}
            />
            <DisableAutoUpdate
                open={isDisableUpdateModalOpen}
                onClose={() => setIsDisableUpdateModalOpen(false)}
            />
            <ResetMachineIdModal
                open={isResetModalOpen}
                onClose={() => setIsResetModalOpen(false)}
            />
            <PostAvailableAccountModal
                open={isPostAccountModalOpen}
                onClose={() => setIsPostAccountModalOpen(false)}
                onSuccess={onSuccess}
            />
        </>
    );
}; 